home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / unix / textmstr.shr / tm.hqx / Source Code ƒ / P / PDoMenuTextMaster.c < prev    next >
Text File  |  1991-05-09  |  6KB  |  225 lines

  1. /*  PDoMenuTextMaster                                                    Handle a selection of the menu bar */
  2.  
  3. /* Unit name:  PDoMenuTextMaster.c   */
  4. /* Function:  This module calls the appropiate menu list */
  5. /*      handler routine. */
  6. /* History: 5/9/91 Original by Prototyper 3.0   */
  7.  
  8.  
  9. #include "PCommonTextMaster.h"    /* Common */
  10. #include "Common_TextMaster.h"    /* Common */
  11. #include "PUtils_TextMaster.h"    /* General Utilities */
  12. #include "Utils_TextMaster.h"    /* General Utilities */
  13.  
  14. #include "AppleMenu.h"    /* Menu handlers */
  15. #include "FileMenu.h"    /* Menu handlers */
  16. #include "EditMenu.h"    /* Menu handlers */
  17. #include "PD_About_Dialog.h"    /* Modal Dialog */
  18. #include "PD_Help_window.h"    /* Modal Dialog */
  19. #include "PD_Help_window_2.h"    /* Modal Dialog */
  20. #include "DoMenuTextMaster.h"    /* Extra menu handler */
  21.  
  22. #include "PDoMenuTextMaster.h"    /* This file */
  23.  
  24. #include "tm.h"                    /* Special #defines for TextMaster */
  25.  
  26.  
  27. /* ======================================================= */
  28.  
  29. void DoMenuApple(short theItem);                                        /* Handle this menu list */
  30. void DoMenuFile(short theItem);                                          /* Handle this menu list */
  31. void DoMenuEdit(short theItem);                                          /* Handle this menu list */
  32.  
  33. /* ======================================================= */
  34.  
  35.  
  36. /* ======================================================= */
  37.  
  38.  
  39. /* Routine: DoMenuApple */
  40. /* Purpose: Handle all menu items in this list */
  41.  
  42. void DoMenuApple( theItem)                                               /* Handle this menu selection */
  43. short        theItem;
  44. {
  45. Boolean    SkipProcessing;                                                 /* TRUE says skip processing */
  46. short    DNA;                                                                 /* For opening DAs */
  47. Str255    DAName;                                                          /* For getting DA name */
  48. GrafPtr    SavePort;                                                        /* Save current port when opening DAs */
  49.  
  50.  
  51.  
  52. SkipProcessing = FALSE;                                                   /* Set to not skip the processing of this menu item */
  53.  
  54. Do_AppleMenu(TRUE,theItem,&SkipProcessing);                       /* Pre menu handler */
  55.  
  56. if (SkipProcessing == FALSE)                                             /* See if process the menu list */
  57.     {
  58.  
  59.     switch (theItem) {                                                        /* Handle all commands in this menu list */
  60.  
  61.         case MItem_About_TextMaste:
  62.             PD_About_Dialog();                                                /* Call a modal dialog */
  63.             break;
  64.  
  65.         default:                                                                 /* Handle the DAs */
  66.             GetPort(&SavePort);                                             /* Save the current port */
  67.             GetItem(Menu_Apple, theItem, DAName);                     /* Get the name of the DA selected */
  68.             DNA = OpenDeskAcc(DAName);                                  /* Open the DA selected */
  69.             SetPort(SavePort);                                                /* Restore to the saved port */
  70.             break;
  71.  
  72.         }                                                                         /* End of item case */
  73.  
  74.     }                                                                             /* End of not SkipProcessing */
  75.  
  76. Do_AppleMenu(FALSE,theItem,&SkipProcessing);                     /* Post menu handler */
  77.  
  78. }                                                                                /* End of procedure */
  79.  
  80. /* ======================================================= */
  81.  
  82.  
  83. /* Routine: DoMenuFile */
  84. /* Purpose: Handle all menu items in this list */
  85.  
  86. void DoMenuFile( theItem)                                                 /* Handle this menu selection */
  87. short        theItem;
  88. {
  89. Boolean    SkipProcessing;                                                 /* TRUE says skip processing */
  90.  
  91.  
  92.  
  93. SkipProcessing = FALSE;                                                   /* Set to not skip the processing of this menu item */
  94.  
  95. Do_FileMenu(TRUE,theItem,&SkipProcessing);                         /* Pre menu handler */
  96.  
  97. if (SkipProcessing == FALSE)                                             /* See if process the menu list */
  98.     {
  99.  
  100.     switch (theItem) {                                                        /* Handle all commands in this menu list */
  101.  
  102.         case MItem_UNIX____Macinto:
  103.                 call_tm(UNIX_TO_MAC);
  104.             break;
  105.  
  106.         case MItem_Macintosh____UN:
  107.                 call_tm(MAC_TO_UNIX);
  108.             break;
  109.  
  110.         case MItem_Help:
  111.             PD_Help_window();                                                /* Call a modal dialog */
  112.             break;
  113.  
  114.         case MItem_Quit:
  115.             doneFlag = TRUE;
  116.             break;
  117.  
  118.         default:
  119.             break;
  120.  
  121.         }                                                                         /* End of item case */
  122.  
  123.     }                                                                             /* End of not SkipProcessing */
  124.  
  125. Do_FileMenu(FALSE,theItem,&SkipProcessing);                        /* Post menu handler */
  126.  
  127. }                                                                                /* End of procedure */
  128.  
  129. /* ======================================================= */
  130.  
  131.  
  132. /* Routine: DoMenuEdit */
  133. /* Purpose: Handle all menu items in this list */
  134.  
  135. void DoMenuEdit( theItem)                                                 /* Handle this menu selection */
  136. short        theItem;
  137. {
  138. Boolean    SkipProcessing;                                                 /* TRUE says skip processing */
  139. Boolean    BoolHolder;                                                       /* For SystemEdit result */
  140.  
  141.  
  142.  
  143. SkipProcessing = FALSE;                                                   /* Set to not skip the processing of this menu item */
  144.  
  145. Do_EditMenu(TRUE,theItem,&SkipProcessing);                         /* Pre menu handler */
  146.  
  147. if (SkipProcessing == FALSE)                                             /* See if process the menu list */
  148.     {
  149.  
  150.     BoolHolder = SystemEdit ( theItem - 1 );                             /* Let the DA do the edit to itself */
  151.  
  152.     if  (BoolHolder == FALSE)                                               /* If not a DA then we get it */
  153.         {                                                                         /* Handle by using a Case statment */
  154.  
  155.         switch (theItem) {                                                     /* Handle all commands in this menu list */
  156.  
  157.             case MItem_Undo:
  158.                 break;
  159.  
  160.             case MItem_Cut:
  161.                 break;
  162.  
  163.             case MItem_Copy:
  164.                 break;
  165.  
  166.             case MItem_Paste:
  167.                 break;
  168.  
  169.             case MItem_Clear:
  170.                 break;
  171.  
  172.             case MItem_Select_All:
  173.                 break;
  174.  
  175.             case MItem_Show_Clipboard:
  176.                 break;
  177.  
  178.             default:                                                              /* Send to a DA */
  179.                 break;
  180.  
  181.             }                                                                      /* End of item case */
  182.         }                                                                         /* End of not BoolHolder */
  183.  
  184.     }                                                                             /* End of not SkipProcessing */
  185.  
  186. Do_EditMenu(FALSE,theItem,&SkipProcessing);                        /* Post menu handler */
  187.  
  188. }                                                                                /* End of procedure */
  189.  
  190. /* ======================================================= */
  191.  
  192. /* Routine: Handle_My_Menu */
  193. /* Purpose: Vector off to the appropiate menu list handler */
  194.  
  195. void Handle_My_Menu(  theMenu, theItem)
  196. short    theMenu;
  197. short    theItem;
  198. {
  199.  
  200.  
  201. switch (theMenu)                                                            /* Do selected menu list */
  202.     {
  203.  
  204.     case Res_Menu_Apple:
  205.         DoMenuApple(theItem);                                              /* Go handle this menu list */
  206.         break;
  207.  
  208.     case Res_Menu_File:
  209.         DoMenuFile(theItem);                                                 /* Go handle this menu list */
  210.         break;
  211.  
  212.     case Res_Menu_Edit:
  213.         DoMenuEdit(theItem);                                                 /* Go handle this menu list */
  214.         break;
  215.  
  216.     default:
  217.         Handle_Other_Menus(theMenu,theItem);                          /* Handle other special menus */
  218.         break;
  219.  
  220.     }                                                                             /* End for the Lists */
  221.  
  222. HiliteMenu(0);                                                                /* Turn menu selection off */
  223. }                                                                                /* End of procedure Handle_My_Menu */
  224.  
  225.